package com.ruoyi.swla2.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.swla2.domain.WqRealtimegatherdata;
import com.ruoyi.swla2.service.IWqRealtimegatherdataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水质检测仪-实时数据Controller
 *
 * @author gdqt
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/swla2/wqRealtimeGatherData")
public class WqRealtimegatherdataController extends BaseController {
    @Autowired
    private IWqRealtimegatherdataService wqRealtimegatherdataService;

    /**
     * 查询水质检测仪-实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:wqRealtimeGatherData:list')")
    @GetMapping("/list")
    public TableDataInfo list(WqRealtimegatherdata wqRealtimegatherdata) {
        startPage();
        List<WqRealtimegatherdata> list = wqRealtimegatherdataService.selectWqRealtimegatherdataList(wqRealtimegatherdata);
        return getDataTable(list);
    }

    /**
     * 导出水质检测仪-实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:wqRealtimeGatherData:export')")
    @Log(title = "水质检测仪-实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WqRealtimegatherdata wqRealtimegatherdata) {
        List<WqRealtimegatherdata> list = wqRealtimegatherdataService.selectWqRealtimegatherdataList(wqRealtimegatherdata);
        ExcelUtil<WqRealtimegatherdata> util = new ExcelUtil<WqRealtimegatherdata>(WqRealtimegatherdata.class);
        util.exportExcel(response, list, "水质检测仪-实时数据数据");
    }

    /**
     * 获取水质检测仪-实时数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('swla2:wqRealtimeGatherData:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID) {
        return success(wqRealtimegatherdataService.selectWqRealtimegatherdataByID(ID));
    }

    /**
     * 新增水质检测仪-实时数据
     */
    @PreAuthorize("@ss.hasPermi('swla2:wqRealtimeGatherData:add')")
    @Log(title = "水质检测仪-实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WqRealtimegatherdata wqRealtimegatherdata) {
        return toAjax(wqRealtimegatherdataService.insertWqRealtimegatherdata(wqRealtimegatherdata));
    }

    /**
     * 修改水质检测仪-实时数据
     */
    @PreAuthorize("@ss.hasPermi('swla2:wqRealtimeGatherData:edit')")
    @Log(title = "水质检测仪-实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqRealtimegatherdata wqRealtimegatherdata) {
        return toAjax(wqRealtimegatherdataService.updateWqRealtimegatherdata(wqRealtimegatherdata));
    }

    /**
     * 删除水质检测仪-实时数据
     */
    @PreAuthorize("@ss.hasPermi('swla2:wqRealtimeGatherData:remove')")
    @Log(title = "水质检测仪-实时数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs) {
        return toAjax(wqRealtimegatherdataService.deleteWqRealtimegatherdataByIDs(IDs));
    }
}
